﻿#region Using Directives
using System;
using System.ComponentModel;
using System.Collections;
using System.Collections.Generic;
using System.Xml.Serialization;
using System.Data;
using System.Linq;
using BesAsm.MasterData.Entities;
using BesAsm.MasterData.Entities.Validation;
using BesAsm.MasterData.Data;
using BesAsm.MasterData.Services;
using Microsoft.Practices.EnterpriseLibrary.Logging;

#endregion

namespace BesAsm.MasterData.Services
{
  /// <summary>
  /// An component type implementation of the 'LINKS' table.
  /// </summary>
  /// <remarks>
  /// All custom implementations should be done here.
  /// </remarks>
  [CLSCompliant(true)]
  public partial class LinkService : BesAsm.MasterData.Services.LinkServiceBase, IArcEntityService<Link>
  {
    #region Constructors
    /// <summary>
    /// Initializes a new instance of the LinkService class.
    /// </summary>
    public LinkService()
      : base()
    {
    }
    #endregion Constructors

    #region IArcEntityService<T> Members

    /// <summary>
    /// Gets an IArcEntity from the default service provider using the ArcGIS Object ID
    /// </summary>
    /// <param name="objectId">The Object ID of the entity to return</param>
    /// <returns>The IArcEntity with a matching Object ID</returns>
    public IArcEntity Get(int objectId)
    {
      return (IArcEntity)base.GetByObjectid(objectId);
    }
    
    /// <summary>
    /// Gets a TList of Link objects that match the provided ObjectId array
    /// </summary>
    /// <param name="oids">The ObjectId array to retrieve</param>
    /// <returns>A TList of Link objects</returns>
    public TList<Link> GetByOids(IEnumerable<int> oids)
    {
      List<int> oidList = oids.ToList();      

      TList<Link> returnList = new TList<Link>();

      DataTable dt = new DataTable("id_table");
      dt.Columns.Add(new DataColumn("oid", typeof(Int32)));

      foreach (int oid in oids)
        dt.Rows.Add(oid);

      return this.SelectByOids(dt);
    }

    /// <summary>
    /// Gets the name of the ObjectId field.
    /// </summary>
    public string OidField { get { return "ObjectId"; } }

    #endregion

  }//End Class

} // end namespace
